<?php
/*
Template Name: News
*/
?>

<?php get_header(); ?>
<!-- lay ra các tin tức moi nhat  -->
<?php

    global $tax;
    global $page;
    
    $page = ((get_query_var("page") != '')? get_query_var("page") : 1);
    
    $featured_news_agrs = array(
        'category_name'        => 'featured-news'
    );

    $featured_news = get_posts($featured_news_agrs);
    
    $id = get_category_by_slug("featured-news")->cat_ID;
    
    $agrs = array(
        "category_name" => "news",
        "category__not_in" => array($id),
        'showposts'     => news_paging,
        'paged'         => $page
        );

    $tax = new WP_Query($agrs);

?>
<div id="news">
    <div class="news-slider-wrapper">
        <div id="news-slider">
            <ul>
                <?php foreach( $featured_news as $post ) : setup_postdata($post); ?>
                <li>
                    <a href="<?php the_permalink();?>" class="news-img"><?php echo get_the_post_thumbnail(get_the_ID(), $size = 'full', $attr = '');?></a>
                    <div class="news-content">
                        <h3 class="news-title"><a href="<?php the_permalink();?>"><?php the_title();?></a></h3>
                        <p class="news-create-date"><?php the_time(get_option('date_format'));?></p>
                        <p class="news-short-content"><?php get_excerpt(get_the_content());?></p>
                    </div>
                </li>
                <?php endforeach;?>
            </ul>
        </div>
    </div>

    <div class="content-wrapper">
        
        <ul class="list-news">
        
        <?php while ($tax->have_posts()): $tax->the_post();?>
            <li>
                <a href="<?php the_permalink();?>" class="news-img"><?php echo get_the_post_thumbnail(get_the_ID(), $size = 'full', $attr = '');?></a>
                <div class="news-content">
                    <h3 class="news-title"><a href="<?php the_permalink();?>"><?php the_title();?></a></h3>
                    <p class="news-create-date"><?php the_time(get_option('date_format'));?></p>
                    <p class="news-short-content"><?php get_excerpt(get_the_content());?></p>
                </div>
            </li>
        <?php endwhile;?>
        </ul>

        <div class="feature-news">
            
        </div>

        <div class="clearfix"></div>
    </div>
    <?php get_paging();?>
</div>
<?php get_footer(); ?>